home *** CD-ROM | disk | FTP | other *** search
/ EnigmA Amiga Run 1999 March / EnigmA AMIGA RUN 35 (1999)(G.R. Edizioni)(IT)[!][issue 1999-03].iso / earcd / grafica / amicad / arexx / aligner.amicad next >
Text File  |  1999-01-01  |  2KB  |  68 lines

  1. /* Alignement des éléments sélectionnés */
  2. /* $VER: Aligner.AmiCAD 1.0 (© R.Florac, 23 mai 1998) */
  3. /* Ne gère correctement que les éléments du même type */
  4.  
  5. options results     /* indispensable pour récupérer le résultat des macros */
  6.  
  7. signal on error     /* pour l'interception des erreurs */
  8. signal on syntax
  9.  
  10. 'ALIGNEMENT=SELECT("Alignement"+CHR(10)+"En haut"+CHR(10)+"En bas"+CHR(10)+"À gauche"+CHR(10)+"À droite")'
  11. alignement=result
  12. select
  13.     when alignement=1 then ligne_base=50000
  14.     when alignement=2 then ligne_base=0
  15.     when alignement=3 then colonne_base=50000
  16.     when alignement=4 then colonne_base=0
  17.     otherwise exit
  18. end
  19.  
  20. objets=0
  21. 'FIRSTSEL'; i=result
  22. do while i>0
  23.     objets=objets+1
  24.     'LINE('i')'; ligne=result
  25.     'COL('i')'; colonne=result
  26.     'WIDTH('i')'; largeur=result
  27.     select
  28.     when alignement = 1 then do
  29.         if ligne<ligne_base then ligne_base=ligne
  30.     end
  31.     when alignement = 2 then do
  32.         if ligne>ligne_base then ligne_base=ligne
  33.     end
  34.     when alignement = 3 then do
  35.         if colonne<colonne_base then colonne_base=colonne
  36.     end
  37.     otherwise do
  38.         if colonne+largeur>colonne_base then colonne_base=colonne+largeur
  39.     end
  40.     end
  41.     'NEXTSEL('i')'; i=result
  42. end
  43.  
  44. if objets<2 then do
  45.     'MESSAGE("Sélectionnez au moins"+CHR(10)+"deux éléments avant"+CHR(10)+"d''appeler ce script")'
  46.     exit
  47. end
  48.  
  49. 'CD='colonne_base':O=FIRSTSEL'; i=result
  50. if alignement=4 then do
  51.     'SAVEALL(-1):O=FIRSTSEL:WHILE(O,MOVE(O,CD-COL(O)-WIDTH(O),0):O=NEXTSEL(O))'
  52.     exit
  53. end
  54.  
  55. 'SAVEALL(-1):O=FIRSTSEL:WHILE(O,IF(ALIGNEMENT<3,MOVE(O,0,'ligne_base'-LINE(O)),MOVE(O,'colonne_base'-COL(O),0)):O=NEXTSEL(O))'
  56.  
  57. exit
  58.  
  59. /* Traitement des erreurs, interruption du programme */
  60. syntax:
  61. erreur=RC
  62. 'MESSAGE("Erreur de syntaxe"+CHR(10)+"en ligne 'SIGL'"+CHR(10)+"'errortext(erreur)'")'
  63. exit
  64.  
  65. error:
  66. 'MESSAGE("Erreur en ligne 'SIGL'")'
  67. exit
  68.